<?php
/*
+--------------------------------------------------------------------------
|   AffiliStore 2
|   ========================================
|   Web: http://www.affilistore.com
|   Email: admin (at) affilistore (dot) com
|	License Type: AffiliStore 2 is NOT open source software and limitations apply 
|   Licence Info: Visit AffiliStore website and click on 'Licence'
+--------------------------------------------------------------------------
*/
require_once('includes/connect.php');
require_once('includes/functions.php');

mysql_select_db($database, $databaseConnect);


$sql = sprintf("SELECT * FROM affiliSt_products1 WHERE prodDB = %d AND dbProdID = %s",
				quote_smart($_GET['proddb']),
				quote_smart($_GET['img']));
$getImgLinks = mysql_query($sql, $databaseConnect) or die(mysql_error());
$merchantImgLink = mysql_fetch_assoc($getImgLinks);

// use thumbnail if avaiable except for single product image
if (isset($_GET['single'])) {
$imagefile = $merchantImgLink['prodImageURL'];
} else if (!isset($_GET['single']) && $merchantImgLink['prodImageSmall'] == NULL) {
$imagefile = $merchantImgLink['prodImageURL'];
} else {
$imagefile = $merchantImgLink['prodImageSmall'];
}


header("Location: $imagefile");

// if images are not showing the comment out the above line and un-comment the following:
//$PE_imgarray = pathinfo($imagefile);
//$iconcontent = file_get_contents($imagefile);
//header("Content-type: image/" . $PE_imgarray["extension"]);
//header('Content-length: ' . strlen($iconcontent));
//echo $iconcontent;
//die(0);
?>